<template>
  <div id='tmpl'>
      <div class="isadd">
            <div class="insubtri" @click="insubtri">-</div>
            <div class="num">{{count}}</div>
            <div class="add" @click="add">+</div>
      </div>
  </div>
</template>
<script>
export default {
  name: "component_name",
  data() {
    return {
      count: 1,
      resobj: {goodId:0,type:'add'}
    };
  },
  props:["initCount","goodId"],
  created(){
      this.count=this.initCount;
  },
  methods: {
    insubtri() {
      this.count--;
      if (this.count < 1) {
        this.count = 1;
      }
      this.sendMessage("insubtri");
    },
    add() {
      this.count++;
      this.sendMessage("add");
    },
    sendMessage(type) {
      this.resobj.goodId=this.goodId;
      this.resobj.type=type;
      //console.log(this.resobj)
      this.$emit("dataObj", this.resobj);
    }
  }
};
</script>
<style lang="css" scoped>
.isadd div {
  display: inline-block;
  border: 1px solid #0094ff;
  width: 30px;
  height: 20px;
  line-height: 20px;
  text-align: center;
}
.isadd div:hover {
  /* 这个样式用于pc端 */
  cursor: pointer;
}
</style>